package com.amiu.shiro.db.role_permission;

import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;


public interface RolePermissionDao {
	@Insert("INSERT INTO roles_permissions(role_id,permission_id,description) VALUES (#{role_id},#{permission_id},#{description})")
	public int createRolePremission(RolePermission rolePermission);
	
	@Delete("DELETE FROM roles_permissions WHERE role_id=#{role_id},permission_id=#{permission_id}")
	public void deleteRolePremission(Long role_id,Long permission_id);
	
//	@Update("@UPDATE roles_permissions SET WHERE ")
//	public void updateRolePremission(Long id);
	
	@Select("SELECT id,role_id,permission_id,description FROM roles_permissions WHERE id=#{id}")
	public RolePermission findById(Long id);
	
	@MapKey("id")
	@Select("SELECT id,role_id,permission_id,description FROM roles_permissions WHERE role_id=#{role_id}")
	public Map<Long, RolePermission> findByRoleId(Long role_id);
	
	@MapKey("id")
	@Select("SELECT id,role_id,permission_id,description FROM roles_permissions WHERE permission_id=#{permission_id}")
	public Map<Long, RolePermission> findByPermissionId(Long permission_id);
	
}
